package main

import (
	"github.com/cloudwego/kitex/pkg/klog"
	"github.com/cloudwego/kitex/pkg/rpcinfo"
	"github.com/cloudwego/kitex/server"
	etcd "github.com/kitex-contrib/registry-etcd"
	"log"
	"myuser/demo/dal"
	"myuser/kitex_gen/demouser/userservice"
	//链路追踪依赖
)

func Init() {
	dal.Init()
}
func main() {
	//服务端的地址 [::]:8888，注意要和demouser下的service中名字保持一致，这里userservice
	Init()                                                        //初始化数据库连接
	r, err := etcd.NewEtcdRegistry([]string{"192.168.1.18:2379"}) // r不应重复使用。
	if err != nil {
		log.Fatal(err)
	}
	svr := userservice.NewServer(new(UserServiceImpl),
		server.WithServerBasicInfo(&rpcinfo.EndpointBasicInfo{ServiceName: "userservice"}),
		server.WithRegistry(r))

	err = svr.Run()

	if err != nil {
		klog.Fatalf("server stopped with error:", err)
	}
}
